<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcCms.Data.ContentCategory>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    MvcCms - <%=ViewData["PageTitle"]%>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <style type="text/css">
        label.error
        {
            float: none;
            color: red;
            padding-left: .5em;
            vertical-align: top;
        }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="contentpage-outerdiv">
        <h2>
            <%=ViewData["PageTitle"]%></h2>
        <span class="field-validation-error">&nbsp;<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
            <%=ViewData["message"].ToString()%>
        </span>
        <% using (Html.BeginForm("CreateContentCategory", "BackOffice", FormMethod.Post, new { id = "form1" }))
           {%>
        <fieldset>
            <legend>Create Content Category</legend>
            <div class="left">
                <p>
                    <label for="Title">
                        Title: (This title will be used to create the URL slug and if the title is changed
                        later the url created from this title will not change)</label>
                    <%= Html.TextBox("Title", "", new { @class = "required" })%>
                    <%= Html.ValidationMessage("Title", "")%>
                </p>
                <p>
                    <label for="Description">
                        Description:</label>
                    <%= Html.TextArea("Description")%>
                    <%= Html.ValidationMessage("Description", "")%>
                </p>
                <p>
                    <label for="SubPageHeader">
                        Sub-Page Header:</label>
                    <%= Html.TextArea("SubPageHeader")%>
                    <%= Html.ValidationMessage("SubPageHeader")%>
                </p>
                <p>
                    <label for="ExternalURL">
                        External URL: (If entered link will go to url entered.)</label>
                    <%= Html.TextBox("ExternalURL")%>
                    <%= Html.ValidationMessage("ExternalURL")%>                
                </p>
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <label for="ShowInNav">
                                ShowInNav: (SubCategories are shown in nav by default)</label>
                            <%= Html.CheckBox("ShowInNav", false)%>
                            <%= Html.ValidationMessage("ShowInNav", "")%>
                        </td>
                        <td>
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <label for="makesubcat">
                                            Make this category a sub category :
                                        </label>
                                        <%= Html.CheckBox("issubcategory", false, new { onclick = "SetShowInNav()" })%>
                                    </td>
                                    <td>
                                        <label for="Category">
                                            Subcategory:</label>
                                        <%= Html.DropDownList("CategoryID")%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <p>
                    <label for="AreaRoute">
                        Use Custom Area Routes: (The url slug will be a link to a custom area with its own routing)
                    </label>
                    <%= Html.CheckBox("UsesCustomAreaRoute", false)%>
                    <%= Html.ValidationMessage("ShowInNav", "")%>
                </p>
                <p>
                    <input type="submit" value="Create" />
                </p>
            </div>
            <div class="right">
                After the category is created you will be taken to the next page where you can change
                the display name of the category to something different than the url slug name created
                here and set other options.
            </div>
            <div class="clear">
            </div>
        </fieldset>
        <% } %>
        <div>
            <%=Html.ActionLink("Back to List", "ManageContentCategories") %>
        </div>
    </div>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
    <script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $("#form1").validate({
            submitHandler: function(form) {
                form.submit();
            }
        });


        function SetShowInNav() {
            var chkShowInNav = $("#ShowInNav:checked").val();
            var chkissubcategory = $("#issubcategory:checked").val();
            if (chkissubcategory == 'true') {
                $("#ShowInNav:checked").click();
                $("#ShowInNav").attr('disabled', true);
            }
            if (chkissubcategory != 'true') {
                $("#ShowInNav").attr('disabled', false);
            }
        }        
    
    
    </script>
</asp:Content>
